<?php
echo $header;
echo $sidebar
?>		
<div class="span10 content">
    <?php echo $hugemenu ?>

    <h1><?php echo lang('blog_edit_title'); ?></h1>
    <?php if ($message) { ?>
        <div class="alert alert-error">
            <a class="close" data-dismiss="alert" href="#">x</a><?php echo $message; ?>
        </div>
    <?php } if ($success) { ?>
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert" href="#">x</a><?php echo $success; ?>
        </div>
    <?php } ?>

    <script type="text/javascript" src="<?php echo base_url() ?>/assets/admin/js/tiny_mce/jquery.tinymce.js"></script>
    <script type="text/javascript">
        $().ready(function() {
            $('textarea.tinymce').tinymce({
                script_url: '<?php echo base_url() ?>/assets/admin/js/tiny_mce/tiny_mce.js',
                theme: "advanced",
                plugins: "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
                theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist",
                theme_advanced_buttons2: "styleselect,formatselect,fontselect,fontsizeselect,|,print,charmap,emotions,iespell,media,advhr",
                theme_advanced_buttons3: "undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor,|,outdent,indent,blockquote",
                theme_advanced_buttons4: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup",
                theme_advanced_toolbar_location: "top",
                theme_advanced_toolbar_align: "left",
                theme_advanced_statusbar_location: "bottom",
                theme_advanced_resizing: true,
                height: "400"
            });
        });
    </script>

    <?php echo form_open_multipart(current_url()); ?>
    <div class="widget">
        <div class="widget-head"><h3 class="heading"><?php echo lang('blog_edit_widget_title') . $title['value'] ?></h3></div>
        <div class="widget-body">
            <div class="row-fluid">
                <div class="span8">	
                    <div class="control-group">
                        <label class="control-label"><?php echo lang('estate_add_title', 'title'); ?></label>
                        <div class="controls">
                            <?php
                            $title['class'] = 'span';
                            echo form_input($title);
                            ?>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label"><?php echo lang('estate_add_content', 'content'); ?></label>
                        <div class="controls">
                            <?php
                            $content['class'] = 'span tinymce';
                            $content['style'] = "width:100%";
                            echo form_textarea($content);
                            ?>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label"></label>
                        <div class="controls">
                            <?php echo form_submit('submit', lang('blog_edit_btn'), 'class="btn btn-success span5"'); ?>
                        </div>
                    </div>
                </div>

                <div class="span4">
                    <div class="well well-small">
                        <div class="control-group">
                            <label class="control-label"><?php echo lang('blog_add_desc', 'price'); ?></label>
                            <div class="controls">
                                <?php
                                $desc['class'] = 'span';
                                echo form_input($desc);
                                ?>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><?php echo lang('blog_add_tags', 'price'); ?></label>
                            <div class="controls">
                                <?php
                                $tags['class'] = 'span';
                                echo form_input($tags);
                                ?>
                            </div>
                        </div>
                    </div>
                    <div class="well well-small blog">                       
                        <div class="thumb">
                            <?php
                            if ($photo) {
                                $file = base_url() . "uploads/" . $photo;
                                if (@getimagesize($file)) echo "<a href='".base_url()."index.php/uploadify/delete_file/$photo' target='_blank' data-cc='confirm' class='deletelink'><img src='".base_url()."uploads/$photo'></a>";
                            }
                            ?>
                        </div>
                        <div class="photos">
                            <?php
                            if ($photo) {
                                $file = base_url() . "uploads/" . $photo;
                                if (@getimagesize($file)) echo "<input type='hidden' value='$photo' name='photo'>";
                            }
                            ?>
                        </div>
                        <div class="control-group">
                            <label class="control-label photo">
                                <?php echo lang('blog_add_one_photo', 'photo'); ?>
                                <?php
                                echo form_upload('userfile', '', 'id="userfile"');
                                echo (isset($error)) ? $error : '';
                                ?>     
                            </label>
                            <div class="controls">
                                <link href="<?php echo base_url(); ?>assets/admin/js/jquery/uploadify_31/uploadify.css" type="text/css" media="screen" rel="stylesheet"/>
                                <script src="<?php echo base_url(); ?>assets/admin/js/jquery/uploadify_31/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
                                <script type="text/javascript">
                                    $(document).ready(function() {
                                        var base_url = '<?php echo base_url(); ?>';
                                        $('#userfile').uploadify({
                                            'auto': true,
                                            'swf': base_url + 'assets/admin/js/jquery/uploadify_31/uploadify.swf',
                                            'uploader': base_url + 'index.php/uploadify/do_upload',
                                            'cancelImg': base_url + 'uploadify-cancel.png',
                                            'fileTypeExts': '*.jpg;*.bmp;*.png;*.tif',
                                            'fileTypeDesc': 'Image Files (.jpg,.bmp,.png,.tif)',
                                            'fileSizeLimit': '5MB',
                                            'fileObjName': 'userfile',
                                            'buttonText': '<?php echo lang('estate_add_photo_btn') ?>',
                                            'multi': false,
                                            'removeCompleted': true,
                                            'onUploadSuccess': function(file, data, response) {
                                                obj = JSON.parse(data);
                                                $('.deletelink').attr('data-cc', 'hidden');
                                                $('.deletelink').trigger('click');
                                                $('.thumb, .photos').empty();
                                                $('.thumb').append('<a class="deletelink" data-cc="confirm" target="_blank" href="' + base_url + 'index.php/uploadify/delete_file/' + obj.file_name + '"><img src="' + base_url + 'uploads/thumbs/' + obj.file_name + '" /></a>');
                                                $('.photos').append('<input type="hidden" name="photo" value="' + obj.file_name + '" />');
                                            }
                                        });

                                    });
                                </script>	
                            </div>
                        </div>
                    </div>

                    <div class="well well-small">
                        <div class="control-group">
                            <h3 class="control-label"><?php echo lang('blog_add_publish'); ?></h3>
                            <div class="controls emlakoptions">
                                <label><?php
                                    echo form_radio($publish);
                                    echo lang('estate_add_publish')
                                    ?></label>
                                <label><?php
                                    echo form_radio($publish2);
                                    echo lang('estate_add_draft')
                                    ?></label>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>

<?php echo form_close(); ?>	

</div>
<!--/content-->

<?php echo $footer ?>